﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel;

namespace EventScavenger
{
    [Serializable]
    public class EventLogView
    {
        public EventLogView() { }
        public EventLogView(string name)
        {
            this.name = name;
        }

        #region Properties
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private string viewPath;
        public string ViewPath
        {
            get { return viewPath; }
            set { viewPath = value; }
        }
        private int eventLogEntryType = 0;
        public int EventLogEntryType
        {
            get { return eventLogEntryType; }
            set { eventLogEntryType = value; }
        }
        private bool showAllLogs = true;
        public bool ShowAllLogs
        {
            get { return showAllLogs; }
            set { showAllLogs = value; }
        }
        private List<MachineLogEntry> machineLogs = new List<MachineLogEntry>();
        public List<MachineLogEntry> MachineLogs
        {
            get { return machineLogs; }
            set { machineLogs = value; }
        }
        private bool showAllEventIDs = true;
        public bool ShowAllEventIDs
        {
            get { return showAllEventIDs; }
            set { showAllEventIDs = value; }
        }
        private List<int> eventIds = new List<int>();
        public List<int> EventIds
        {
            get { return eventIds; }
            set { eventIds = value; }
        }
        private bool showAllSources = true;
        public bool ShowAllSources
        {
            get { return showAllSources; }
            set { showAllSources = value; }
        }
        private List<string> sources = new List<string>();
        public List<string> Sources
        {
            get { return sources; }
            set { sources = value; }
        }
        private string filterText = "";
        [DefaultValueAttribute("")]
        public string FilterText
        {
            get { return filterText; }
            set { filterText = value; }
        } 
        #endregion

        static public EventLogView LoadViewFromFile(string viewPath)
        {
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();

            xdoc.Load(viewPath);
            EventLogView eventLogView = (EventLogView)Serializer.DeserializeXML(xdoc.OuterXml, typeof(EventLogView));
            eventLogView.viewPath = viewPath;
            return eventLogView;
        }

        public override string ToString()
        {
            return name;
        }
    }
}
